package tech.dx.springdb.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tech.dx.springdb.entity.CourseInfo;
import tech.dx.springdb.respository.CourseInfoRepository;
import tech.dx.springdb.service.CourseInfoService;

/**
 * @ClassName CourseInfoServiceImpl
 * @Description TODO
 * @Author daoxuan
 * @Date 2019/4/1 12:20
 * @Version 1.0
 */
@Service
public class CourseInfoServiceImpl implements CourseInfoService {

    @Autowired
    private CourseInfoRepository courseInfoRepository;
    @Override
    public CourseInfo getById(long id) {
        return  courseInfoRepository.findById(id).get();
    }

    @Override
    public CourseInfo add(CourseInfo courseInfo) {
        CourseInfo save = courseInfoRepository.save(courseInfo);
        return save;
    }

    @Override
    public CourseInfo update(CourseInfo courseInfo) {
        return courseInfoRepository.save(courseInfo);
    }
}
